<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/tagDeclare.jsp"%>
<%@include file="/headDeclare.jsp"%>
<html>
 <head>
<style type="text/css"> 
	fieldset,table,tr,td {margin:0; padding:0;}
	td {padding:0 5px 0 10px;border:1px;}
	form label {font-weight:bold;}
	table{border-collapse: collapse;}
  </style>

  <script type="text/javascript">
  var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
	$(document).ready(function() {
        $("#btn_search").click(function(){
            $("#curPage").val(1);
            $("#userForm").submit();
        });
      
	}); 
	function choose(){
		var id = $("#roleId").val();	
		var select = "";
		$('input[type="checkbox"][name="select"]:checked').each(
                function() {
                	select +=","+$(this).val();   
                }
         );
		if (!isEmpty(select)) {
			select = select.substring(1);
		}
		$.post("roleuser/update.do",{id:id,select:select},function(result){
			var res = eval('(' + result + ')');
			if (res.code == 0) {
				$.ligerDialog.error(res.message);
				return false;
			} else {
				window.parent.searchForm.submit();
				dialog.close();
			}
		});
	}

  </script>
 </head>

 <body>
 
 <div style="width: 100%;">
  <div style="margin: auto;margin-top: 10px;" >
      <form id="userForm"  method="post" action="user/choose.do">
      <input type="hidden" name="roleId" id="roleId" value="${roleId }" />
        <table>
          <tr>
            <td><label for="name">用户名:</label></td>
            <td><input type="text" class="ldText" name="userName" id="userName" value="${userName }"/></td>
            <td><input type="submit" id="btn_search" class="ldBtnBlue" value="查询"  /></td>
          </tr>
        </table>
      </form>
  </div>
  <hr />
  <div>
  	<table border="0" id="userTable" cellspacing="0" cellpadding="0" width="100%" class="ld-datagrid">
	    <tr>
	      <th>选择</th>
          <th >用户名</th>
          <th >姓名</th>
 	    </tr> 
	  	<c:forEach items="${list}" var="user" varStatus="status">
	  	<tr>
	  	  <td><input type="checkbox" name="select" value="${user.id }" /></td>
	  	  <td >${user.userName }</td>
	  	  <td >${user.showName }</td>
	  	</tr>
	  	</c:forEach>
  	</table>
  </div>
	<hr />
  <div>
      <div style="text-align:right;">
      		<input type="button" name="submit" value="提交" onclick="choose()" class="ldBtnGray" style="float: left;" />
	      <form action="user/choose.do" name="pagerForm" id="pagerForm">
	      	<jt:pager action="pagerForm"></jt:pager>
	      </form>
      </div>
  </div>
 </div>
 </body>
</html>

